package common.inter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.kit.Ret;

import common.kit.PropKits;

public class GlobalExceptionInterceptor implements Interceptor {
    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionInterceptor.class);
    @Override
    public void intercept(Invocation inv) {
    	if (PropKits.isDevMode()) {
			inv.invoke();
			return ;
		}
        try {
        	inv.invoke();
        }catch (Exception e) {
            logger.error("服务器异常", e);
            inv.getController().renderJson(Ret.fail("err","服务器异常，请联系管理员"));
        }
    }
}
